<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/Hui-iconfont/1.0.8/iconfont.min.css" />
<style type="text/css">
.row {
	margin-top: 15px
}
</style>
<title>景区详情</title>
</head>
<body>
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="row cl">
				<label class="form-label col-xs-2">景区图片：</label>
				<div class="formControls col-xs-4">
					<img src="${detail.img}" width="120px" height="50px" id="img" name="img" /> <span class="btn-upload form-group">
						<form id="imgForm" method="post" enctype="multipart/form-data">
							<input type="hidden" id="id" name="scenicSpotId" value="${detail.id}" /> 
								<a href="javascript:void();" class="btn btn-primary upload-btn">
								 	<i class="Hui-iconfont">&#xe642;</i>修改
								</a>
							 <input type="file" multiple name="imgFile" class="input-file" id="file1" />
						</form>
					</span>
				</div>
			</div>
			<form id="dataForm">
				<div class="row cl">
					<label class="form-label col-xs-2"><span class="c-red">*</span>景区名称：</label>
					<div class="form-label col-xs-4">
						<input class="input-text required" type="text" value="${detail.name}" id="name" name="name"></input>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-2">景区描述：</label>
					<div class="formControls col-xs-8">
						<input class="input-text" type="text" value="${detail.descript}" id="descript" name="descript"></input>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-2"><span class="c-red">*</span>景区每天开放时间：</label>
					<div class="formControls col-xs-8">
						<input class="input-text required" type="text" value="${detail.openTime}" id="openTime" name="openTime"></input>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-2">景区位置：</label>
					<div class="formControls col-xs-4">
						<input class="input-text" type="text" value="${detail.area}" id="area" name="area"></input>
					</div>
					<label class="form-label col-xs-2"><span class="c-red">*</span>景区默认车牌前缀：</label>
					<div class="formControls col-xs-4">
						<input class="input-text required" maxlength="2" type="text" value="${detail.carNoPrefix}" id="carNoPrefix"
							name="carNoPrefix"></input>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-2">资费说明：</label>
					<div class="formControls col-xs-8">
						<input class="input-text" type="text" value="${detail.priceDesc}" id="priceDesc" name="priceDesc"></input>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-2">使用说明：</label>
					<div class="formControls col-xs-8">
						<input class="input-text" type="text" value="${detail.useDesc}" id="useDesc" name="useDesc"></input>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-2">退票规则：</label>
					<div class="formControls col-xs-8">
						<input class="input-text" type="text" value="${detail.returnTicketRule}" id="returnTicketRule"
							name="returnTicketRule"></input>
					</div>
				</div>
				<div class="row cl" style="text-align: center">
					<button id="updateBtn" class="btn btn-secondary radius size-L" type="button">确定</button>
					<button id="cancelBtn" class="btn btn-secondary radius size-L" type="button">取消</button>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		$(function() {
			$("#img").click(function() {
				var photosJson = new Object();
				var photoArray = new Array();
				var photo = new Object();
				photo.src = $(this).attr("src");
				photoArray[0] = photo;
				photosJson.data = photoArray;
				layer.photos({
					photos : photosJson
				});
			});

			$("#updateBtn").click(function() {
				console.log(1111)
				if(!$("#dataForm").valid()) {
					return;
				}
				var updateData = new Object();
				updateData.img = $("#img").attr("src");
				updateData.name = $("#name").val();
				updateData.descript = $("#descript").val();
				updateData.openTime = $("#openTime").val();
				updateData.area = $("#area").val();
				updateData.carNoPrefix = $("#carNoPrefix").val();
				updateData.priceDesc = $("#priceDesc").val();
				updateData.useDesc = $("#useDesc").val();
				updateData.returnTicketRule = $("#returnTicketRule").val();
				updateData.id = $("#id").val();
				$.post("${ctx}/scenicSpot/update", updateData, function(data) {
					if (data.result) {
						layer.confirm('更新成功!', {
							btn : [ '确定' ]
						}, function() {
							var index = parent.layer.getFrameIndex(window.name);
							parent.reloadData();
							parent.layer.close(index);
						});
					} else {
						layer.confirm("更新失败!" + data.errorMsg, {
							btn : [ '确定' ]
						}, function() {
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
						});
					}
				});
			});

			$("#cancelBtn").click(function() {
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			});

			$("#file1").change(function() {
				$("#imgForm").attr("action","${ctx}/file/upload");
				$("#imgForm").attr("target","blankFrame");
				$("#imgForm").submit();
			});
		});

		function refreshUpload(img) {
			$("#img").attr("src",img);
		}
	</script>
	<iframe id="blankFrame" name="blankFrame" style="display: none"> </iframe>
</body>
</html>
